#include<bits/stdc++.h>
using namespace std;
#define int long long

bool vis['z' + 5];

signed main() {
	string s;
	getline(cin, s);

	string t = s;
	sort(t.begin(), t.end());

	if (t != s) {
		cout << "0";
		return 0;
	}

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (vis[s[i]]) {
			cout << "0";
			return 0;
		}

		vis[s[i]] = 1;

		ans = ans * 26 + s[i] - 'a' + 1 - i;
	}
	cout << ans;
	return 0;
}
